package com.dianrui.moonfire.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.dianrui.moonfire.R;


/**
 * 更新对话框
 * @author lzy
 */

public class CreateTipUtils {

    public static void createWaringTip(String contents, Context context, final OnTipDialogClickListener onTipDialogClickListener) {
        final Dialog dialog = new Dialog(context, R.style.RcDialogs);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_tip, null);
        TextView content =view.findViewById(R.id.content);
        TextView cancel = view.findViewById( R.id.cancel);
        TextView okey = view.findViewById(R.id.okey);
        content.setText(contents);
        okey.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                if (onTipDialogClickListener != null) {
                    onTipDialogClickListener.onOkey();
                }
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
                if (onTipDialogClickListener != null) {
                    onTipDialogClickListener.onCancel();
                }
            }
        });

        dialog.setContentView(view);
        dialog.setCanceledOnTouchOutside(false);
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                dialog.show();
            }
        },1000);
    }



    public interface OnTipDialogClickListener {
        void onCancel();


        void onOkey();
    }



    public interface OnTipDialogClickListener2 {
        void onOkey();

        void onDoNotShow();

    }


}
